<template>
    <div>后台首页 {{$store.state.user.username}}</div>
    <el-button @click="handleLogout">退出登录</el-button>
</template>
<script setup>
import {showModal,toast} from '~/composables/util'
import {removeToken} from '~/composables/auth'
import {useStore} from 'vuex'
import {logout} from '~/api/manager'
import {useRouter} from 'vue-router'
const store = useStore()
const router = useRouter()
function handleLogout(){
  showModal("是否要退出登录？").then(res=>{
    // console.log("退出登录")
    logout().finally(()=>{
      store.dispatch("logout")
      router.push("/login")
      toast("退出登录成功")
    })
  })
}
</script>